package com.maycurobj.pojo;

import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * 每刻外部单据对象
 * 接受到的请求参数
 */
@Data
public class MayCurOutVoucher {
    /**
     * 请求用户编码
     */
    private String employeeId;
    /**
     * 关键字
     */
    private String keyWord;
    /**
     * 每页长度
     */
    private Integer length;
    /**
     * 页偏移量
     */
    private Integer start;
    /**
     * 是否校验
     */
    private Boolean verification;
    /**
     * 单据内容（formData）
     */
    private Map<String,Object> formData;

    /**
     * 获取外部单据 请求时单据类型
     * @return
     */
    public String getVoucherCode(){
        try {
            String rs="";
            if(formData.containsKey("formSubTypeBizCode")){
                Map<String,Object> bizCode=(Map<String,Object>)formData.get("formSubTypeBizCode");
                Map<String, String> value = (Map<String,String>)bizCode.get("value");
                rs=value.get("text");
            }
            return rs;
        } catch (Exception e) {

            return null;
        }
    }

    public String getLoanUser() {
        String emp= null;
        try {
            emp = "";
            if(formData.containsKey("loanUser")){
                Map<String, Object> bizCodeUser = (Map<String,Object>)formData.get("loanUser");
                List<Map<String,Object>> value = (List<Map<String,Object>>) bizCodeUser.get("value");
                for (Map<String, Object> m : value) {
                    emp=m.get("employeeNo").toString();
                }
            }
            return emp;
        } catch (Exception e) {
            return null;
        }
    }
}
